﻿using BBICMS.Model;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;

namespace BBICMS.Repository.Configuration
{
    class CustomDatabaseInitializer :
        //DropCreateDatabaseIfModelChanges<DataContext>
    CreateDatabaseIfNotExists<DataContext>
    {
        protected override void Seed(DataContext context)
        {
            string[] descriptions = new string[5] { 
                "USB电源适配器",
                "单口USB车载充电器",
                "双口USB车载充电器",
                "苹果线据线",
                "Mirco USB 5P 线据线"               
            };

            int count = 5;
            while ((count--) != 0)
            {
                Product product = new Product();
                product.ProductNo = string.Format("No{0}", count);
              //  product.ProductName = descriptions[count];
                //product.Description = string.Format("No{0}个产品", count);
                //product.Parameters = string.Format("No{0}个产品描述", count);              
                product.Thumbnail = string.Format("home-{0}.jpg", ((count % 2) == 1) ? 2 : 1);
              
                context.Products.Add(product);
            }
            // */

            //Role admin = new Role();
            //admin.RoleName = "admin";
            //context.Roles.Add(admin);

            //Role mgr = new Role();
            //mgr.RoleName = "manager";
            //context.Roles.Add(mgr);

            //Role usr = new Role();
            //usr.RoleName = "user";
            //context.Roles.Add(usr);

            base.Seed(context);
        }
    }
}
